package com.sneakxy.cloudbase.platform.repository;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.sneakxy.cloudbase.platform.bean.AccountRole;
import com.sneakxy.cloudbase.platform.bean.AccountRoleId;

/**
 * 
 * @author 潜行的青衣
 * @see
 */
@Repository
public interface AccountRoleRepository extends BaseRepository<AccountRole, AccountRoleId> {

	@Select("select role_id from ${tableName} where account_id=#{accountId}")
	public List<String> findRoles(@Param("accountId") String accountId, @Param("tableName") String tableName);
	
	@Delete("delete from t_mb4j_account_role where role_id=#{roleId}")
	public int deleteByRoleId(@Param("roleId") String roleId);
	
	@Delete("delete from ${tableName} where account_id=#{accountId}")
	public int deleteByAccountId(@Param("accountId") String accountId, @Param("tableName") String tableName);
	
}
